﻿#include "App.h"

int APIENTRY wWinMain(
    _In_ HINSTANCE, 
    _In_opt_ HINSTANCE,
    _In_ LPWSTR,
    _In_ int)
{
    try
    {
        return App{}.Go();
        //Window wnd(600, 400, "Donkey Fart Box");

        //MSG msg = {};
        //while (msg.message != WM_QUIT) {     // 非退出事件
        //    if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
        //        TranslateMessage(&msg);//翻译消息
        //        DispatchMessage(&msg);//分发消息
        //        if (wnd.kbd.KeyIsPressed(VK_MENU)) {
        //            MessageBox(nullptr, "ddddddddd", "", MB_OK);
        //        }
        //        static int i = 0;
        //        while (!wnd.mouse.IsEmpty()) {
        //            const auto e = wnd.mouse.Read();
        //            switch (e.GetType()) {
        //            case Mouse::Event::Type::Leave:
        //                wnd.SetTitle("Gone");
        //                break;
        //            case Mouse::Event::Type::Move:
        //                {
        //                    std::ostringstream oss;
        //                    oss << "Mouse moved to (" << wnd.mouse.GetPosX() << "," << wnd.mouse.GetPosY() << ")";
        //                    wnd.SetTitle(oss.str()); 
        //                }
        //                break;
        //            case Mouse::Event::Type::WheelDown:
        //                {
        //                    --i;
        //                    std::ostringstream oss;
        //                    oss << "Down " << i;
        //                    wnd.SetTitle(oss.str());
        //                }
        //                break;
        //            case Mouse::Event::Type::WheelUp:
        //                {
        //                    ++i;
        //                    std::ostringstream oss;
        //                    oss << "Up " << i;
        //                    wnd.SetTitle(oss.str());
        //                }
        //                break;
        //            }
        //        }
        //    }
        //    //其它工作
        //    wnd.MainLoop();
        //}
 
        //return (int) msg.wParam;
    }
    catch (const ChiliException& e) {
        MessageBox(nullptr, e.what(), e.GetType(), MB_OK | MB_ICONEXCLAMATION);
    }
    catch (const std::exception& e) {
        MessageBox(nullptr, e.what(), "standard Exception", MB_OK | MB_ICONEXCLAMATION);
    }
    catch (...) {
        MessageBox(nullptr, "No details available", "Unknown Exception", MB_OK | MB_ICONEXCLAMATION);
    }
    return -1;
}
